package org.unt.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;


public class OracleDataSourceRegisterJNDI {
/*
	public static void main(String[] args) {
		System.out.println(test());
	}

	public static String test() {

		try {

			OracleDataSource ds = new OracleDataSource();

			ds.setDescription("Oracle");
			ds.setServerName("yvash980.inetpsa.com");
			ds.setPortNumber(1521);
			ds.setUser("altj");
			ds.setPassword("altj");

			ds.setDriverType("thin");
			ds.setNetworkProtocol("tcp");
			ds.setDatabaseName("ALT");

			Hashtable env = new Hashtable();
			env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
			env.put(Context.PROVIDER_URL, "file:C:\\Java\\JDBCDataSource");

			Context ctx = new InitialContext(env);

			ctx.rebind("jdbc/sampledb", ds);

			OracleDataSource odsconn = (OracleDataSource) ctx.lookup("jdbc/sampledb");
			Connection conn = odsconn.getConnection();
			Statement statement = conn.createStatement();

			ResultSet rs = statement.executeQuery("select count(*) from ALT.ALTQT999");
			rs.next();
			int res = rs.getInt(1);

			return "" + res;

		} catch (Exception e) {

			return e.getMessage();
		}
	}*/
}
